'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
    const { router, controller } = app;

    app.beforeStart(async() => {
        // await app.model.sync({ alter: true }); //force  false 为不覆盖 true会删除再创建; alter true可以 添加或删除字段;
    });
    const jwt = app.middleware.checkJwt(app.config.jwt);
    router.get('/login', controller.home.index)

    router.post('/user/login', controller.user.show)
    router.get('/user/info', jwt, controller.user.index)
        // router.get('/user/create', jwt, controller.user.create)

    router.post('/wx/user/login', controller.wxuser.show)

    router.get('/cats/index', controller.cats.index)
    router.post('/cats/add', controller.cats.create)
    router.get('/cats/delete/:id', jwt, controller.cats.destroy)

    router.get('/cats/list', controller.cats.get)
    router.post('/wx/decrypt', controller.wxuser.decrypt)
    router.post('/wx/user/info', controller.wxuser.info)

    router.get('/wx/getToken', controller.wxuser.getToken)


    router.get('/view/index', controller.views.index)
    router.get('/view/databaseCollectionGet', controller.wxcloud.databaseCollectionGet)

};